home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <windowsx.h>
- #include "blt.h"
- #include "dib.h"
- #include "dva.h"
-
- /*----------------------------------------------------------------------------*\
- \*----------------------------------------------------------------------------*/
- void DrawDVA(HDC hdc, int x, int y, int dx, int dy);
- void DrawDVAX(HDC hdc, int x, int y, int dx, int dy);
-
- /*----------------------------------------------------------------------------*\
- \*----------------------------------------------------------------------------*/
- extern "C" FAR PASCAL DVABlt(LPBITMAPINFOHEADER,LPVOID,LONG,LONG,LONG,LONG,
- LPBITMAPINFOHEADER,LPVOID,LONG,LONG);
-
- extern "C" FAR PASCAL StretchDIB(
- LPBITMAPINFOHEADER,LPVOID,UINT,UINT,UINT,UINT,
- LPBITMAPINFOHEADER,LPVOID,UINT,UINT,UINT,UINT);
-
- typedef void (FAR PASCAL CONVERTPROC)(
- LPVOID pd, // --> dst.
- LONG dd, // offset to start at
- LONG nd, // dst_next_scan.
- LPVOID ps, // --> source.
- LONG ds, // offset to start at
- LONG ns, // src_next_scan.
- LONG dx, // pixel count.
- LONG dy, // scan count.
- LPVOID pc); // pixel convert table.
-
- extern "C" CONVERTPROC copy_8_8, convert_8_8;
-
- /*----------------------------------------------------------------------------*\
- \*----------------------------------------------------------------------------*/
-
- HDVA hdva;
- BITMAPINFOHEADER biScreen;
- LPVOID lpScreen;
-
- BOOL InitDVA(void)
- {
- if (hdva != NULL)
- {
- if (lpbiApp)
- return lpbiApp->biBitCount == biScreen.biBitCount;
- else
- return TRUE;
- }
-
- HDC hdc = GetDC(NULL);
- hdva = DVAOpenSurface(hdc, 0);
- ReleaseDC(NULL,hdc);
-
- if (hdva)
- {
- lpScreen = DVAGetSurfacePtr(hdva);
- biScreen = *DVAGetSurfaceFmt(hdva);
- }
-
- return hdva != NULL;
- }
-
- void DrawDVA(HDC hdc, int x, int y, int dx, int dy)
- {
- DWORD dw;
-
- if (gfBackPal)
- {
- DrawDVAX(hdc, x, y, dx, dy);
- return;
- }
-
- dw = GetDCOrg(hdc);
-
- x = x + LOWORD(dw);
- y = y + HIWORD(dw);
-
- if (DVABeginAccess(hdva, x, y, dx, dy))
- {
- y = y + dy-1;
- y = abs((int)biScreen.biHeight)-1 - y;
-
- if (dx == bm.bmWidth && dy == bm.bmHeight)
- DVABlt(&biScreen, lpScreen, x, y,
- bm.bmWidth * bm.bmBitsPixel/8,bm.bmHeight,
- lpbiApp, lpDibBits, 0, 0);
- else
- StretchDIB(&biScreen, lpScreen, x, y, dx, dy,
- lpbiApp, lpDibBits, 0, 0, bm.bmWidth, bm.bmHeight);
-
- DVAEndAccess(hdva);
- }
- }
-
- void DrawDVAX(HDC hdc, int x, int y, int dx, int dy)
- {
- DWORD dw;
-
- dw = GetDCOrg(hdc);
-
- x = x + LOWORD(dw);
- y = y + HIWORD(dw);
-
- if (DVABeginAccess(hdva, x, y, dx, dy))
- {
- y = y + bm.bmHeight-1;
-
- dw = (DWORD)(UINT)y * (DWORD)(UINT)DibWidthBytes(&biScreen) +
- x * bm.bmBitsPixel/8;
-
- convert_8_8(lpScreen, dw, -(int)DibWidthBytes(&biScreen),
- lpBitmapBits, OffsetScan0, -(int)bm.bmWidthBytes,
- bm.bmWidth*bm.bmBitsPixel/8, bm.bmHeight, BitmapTranslate);
-
- DVAEndAccess(hdva);
- }
- }
-